import * as API from '../../api'

export default {
  // 开启命名空间模式
  // namespaced: true,
  state: {
    rankinglist: [],
    commendsongs: []
  },
  getters: {},
  actions: {
    async getRankingList({ commit }) {
      const rankinglist = await API.rankinglist.reqGetRankingList()
      commit('GET_RANKING_LIST', rankinglist)
    },
    async getCommendSongs({ commit }, id) {
      const commendsongs = await API.rankinglist.reqGetCommendSongs(id)
      const commendSongs = commendsongs.playlist
      // console.log(commendSongs)
      commit('GET_COMMEND_SONGS', commendSongs)
    }
  },
  mutations: {
    GET_RANKING_LIST(state, rankinglist) {
      state.rankinglist = rankinglist
    },
    GET_COMMEND_SONGS(state, commendSongs) {
      state.commendsongs = commendSongs
    }
  }
}
